package realQuestion.tuan8_19;

import java.util.Scanner;

public class Test2 {


}
class  Main1{
    static int find(int[] nums){
    int max=Integer.MIN_VALUE;
    int index=-1;
        for (int i = 0; i < nums.length-1; i++) {
            if (nums[i]*nums[i+1]>max){
                max=nums[i]*nums[i+1];
                index=i;
            }
        }
        int sum=0;
        int cur=0;
        while (cur<= nums.length-1){
            if (cur==index){
                sum+=max;
                cur=cur+2;
            }else {
                sum+=nums[cur++];
            }

        }

        return  sum;


    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i]=scanner.nextInt();
        }
        System.out.println(find(a));

    }


}
